package user.view;

import java.util.ArrayList;
import java.util.Collection;
import java.util.LinkedList;

import javax.swing.JPanel;
import javax.swing.text.JTextComponent;

import system.activity.MainListener;

public abstract class Controls extends JPanel
{
	MainListener listener;
	
	public abstract Collection<String> getControlsValues();
	
	abstract void setListener(MainListener listener);

	abstract protected LinkedList<JTextComponent> elementsQueue();

	abstract protected void init();
	
	abstract String getClassName();

	protected void initFromHistory(ArrayList<String> params)
	{
		init();
		LinkedList<JTextComponent> components = elementsQueue();
		for(int i = 0; i< params.size(); i++)
		{
			components.get(i).setText(params.get(i));
			
		}
		this.listener.needRepaint();
		getClassName();
	}
	
	public String getDescriptionForHistory()
	{
		String resultString = getClassName()+";";
		LinkedList<JTextComponent> components = elementsQueue();
		for(int i = 0; i< components.size(); i++)
		{
			resultString+=components.get(i).getText()+";";
		}
		return resultString;
	}
}
